package pl.edu.uj.tcs.blef.protocol;

/**
 * OK answer protocol request factory.
 * @author Maciej Bendkowski
 *
 */
public class OKRequestFactory implements RequestFactory {

	@Override
	public Request build(Object[] parameters, RequestHandler handler) throws BuildFailedException {
		if(parameters.length != 1) throw new BuildFailedException("Only one argument expected.");
		try{
			String message = (String)parameters[0];
			return new OKRequest(message, handler);
		} catch(ClassCastException e) { throw new BuildFailedException(e.getMessage()); }
	}

	@Override
	public Request parse(String message, RequestHandler handler) throws ParseFailedException, BuildFailedException {
		//TODO Add parse in client.
		return null;
	}

}
